import { post } from '@/utils/fetch';

export const getRoleList = (data) => post('/usercenter-admin-app/admin/sysRole/permissionSelect', data);

export const getResourceTree = ({ appCode }) =>
  post(
    `/usercenter-admin-app/admin/sysRoleResourceAction/selectResourceActionTree?appCode=${appCode}`,
    {},
  );

export const getAuthByRoleCode = (data) =>
  post('/usercenter-admin-app/admin/sysRoleResourceAction/selectResourceActionListByRole', data);

export const updateResourceActionListByRole = ({ roleCode, appCode, resourceIds, data }) =>
  post(
    `/usercenter-admin-app/admin/sysRoleResourceAction/updateResourceActionListByRole?roleCode=${roleCode}&appCode=${appCode}&resourceIds=${resourceIds.join(
      ',',
    )}`,
    data,
  );

export const selectResourceActionByUser = (data) =>
  post('/usercenter-admin-app/admin/sysUser/selectResourceActionByUser', data);
